//价格区间操作
function select_price(url) {
    var min = $("#min_price").val();
    var max = $("#max_price").val();
    if (min != '' && max != '') {
        var re = /^\d+(\.\d)?$/;
        if (!re.test(min) || !re.test(max)) {
            alert('价格输入不合法!');
            $("#min_price").val('');
            $("#max_price").val('');
            $("#min_price").focus();
            $("#max_price").focus();
            return false;
        }
        min = parseInt(min);
        max = parseInt(max);
        if (min < 1 || min > 200 || max < 1 || max > 200 || min > max) {
            alert('请输入合理的价格区间!');
            $("#min_price").val('');
            $("#max_price").val('');
            $("#min_price").focus();
            $("#max_price").focus();
            return false;
        }
        location.href = url + '?prices=' + min + '-' + max;
    }
    else {
        alert('请输入价格区间!');
        $("#min_price").focus();
        $("#max_price").focus();
        return false;
    }
}
//收藏车型
function collect_car(uid, mark_type, obj_id, obj_title, obj_pic) {
    if (uid == '0' || uid == '') {
        alert('登录之后才能收藏车型，请登录！');
        location.href = '/Login/iLogin.html';
        return false;
    }
    $.ajax({
        type: "GET",
        url: "/Home/CarModel/collect_car",
        data: {uid: uid, mark_type: mark_type, obj_id: obj_id, obj_title: obj_title, obj_pic: obj_pic},
        dataType: "json",
        success: function (result) {
            if (result == 'success') {
                alert('车型已收藏');
                $('#collect_car_button').removeClass('icon180');
                $('#collect_car_button').addClass('icon98');
            } else if (result == 'have') {
                alert('您已经收藏过该车型！');
                $('#collect_car_button').addClass('icon98');
            } else if (result == 'err') {
                alert('收藏失败！');
            } else {
                alert('收藏失败！');
            }
        },
        error: function (x, e) {
            alert('收藏失败！');
        }
    });
}
//询价
function ask_price(uid, url) {
    if (uid == '0' || uid == '') {
        alert('登录之后才能询价，请登录！');
        location.href = '/Login/iLogin.html';
        return false;
    }
    else {
        location.href = url;
        return true;
    }
}